﻿using System;
using SpecFlowTfsLinker.Entities;

namespace SpecFlowTfsLinker.Test.Resources
{
    public static class TestResource
    {
        public const int IdUserStory = 1;
    }

    public static class UserStoryResources
    {
        public static class Calculation 
        {
            public const string Title = "Complete Calculator";
            public const string CleanedTitle = "CompleteCalculator";
            public const string Description = "In order to create a calculator, I want the system calculate an addition and a soustraction";

            public static UserStory CompleteUserStory
            {
                get
                {
                    return UserStory.Builder
                        .Id(TestResource.IdUserStory)
                        .Title(Title)
                        .Description(Description)
                        .AddTestCase(TestCaseResources.Addition.CompleteTestCase)
                        .AddTestCase(TestCaseResources.Addition.CompleteTestCase)
                        .Build();
                }
            }

            public static string CompleteFeatureFile
            {
                get
                {
                    return "Feature: " + Title +
                           Environment.NewLine +
                           Description +
                           Environment.NewLine +
                           Environment.NewLine +
                           TestCaseResources.Addition.CompleteFeatureTestCase +
                           Environment.NewLine +
                           Environment.NewLine +
                           TestCaseResources.Addition.CompleteFeatureTestCase;
                }
            }

            private static string Using = "using TechTalk.SpecFlow;" + Environment.NewLine +
                                          "using Microsoft.VisualStudio.TestTools.UnitTesting;";

            public static string Print
            {
                get
                {
                    return Using +
                           Environment.NewLine +
                           "namespace Test" +
                           Environment.NewLine +
                           "{" +
                           Environment.NewLine +
                           "[Binding]" +
                           Environment.NewLine +
                           "public class Calculator" +
                           Environment.NewLine +
                           "{" +
                           Environment.NewLine +
                           TestCaseResources.Addition.Given.CompleteMethodHeader +
                           Environment.NewLine +
                           TestCaseResources.Addition.GivenAnd.CompleteMethodHeader +
                           Environment.NewLine +
                           TestCaseResources.Addition.GivenSecondAnd.CompleteMethodHeader +
                           Environment.NewLine +
                           TestCaseResources.Addition.When.CompleteMethodHeader +
                           Environment.NewLine +
                           TestCaseResources.Addition.WhenAnd.CompleteMethodHeader +
                           Environment.NewLine +
                           TestCaseResources.Addition.Then.CompleteMethodHeader +
                           Environment.NewLine +
                           TestCaseResources.Addition.ThenAnd.CompleteMethodHeader +
                           Environment.NewLine +
                           "}" +
                           Environment.NewLine +
                           "}" +
                           Environment.NewLine;
                }
            }
        }

        public static class Bowling
        {
            public static UserStory CompleteUserStory
            {
                get
                {
                    return UserStory.Builder
                        .Id(TestResource.IdUserStory)
                        .Title(TestCaseResources.GutterGame.Title)
                        .Description(TestCaseResources.GutterGame.Description)
                        .AddTestCase(CompleteTestCase)
                        .AddTestCase(CompleteTestCase)
                        .AddTestCase(CompleteTestCase)
                        .Build();
                }
            }

            private static TestCase CompleteTestCase
            {
                get
                {
                    return PartialTestCase
                        .Then(TestCaseResources.GutterGame.And.BaseStatement)
                        .Build();
                }
            }

            public static TestCase.BuilderTestCase PartialTestCase
            {
                get
                {
                    return TestCase.Builder
                        .Name(TestCaseResources.GutterGame.Name)
                        .Given(TestCaseResources.GutterGame.Given.BaseStatement)
                        .When(TestCaseResources.GutterGame.When.BaseStatement)
                        .Then(TestCaseResources.GutterGame.Then.BaseStatement);
                }
            }
        }

        public static class WeirdAndComplex
        {
            private const string Title = "Special Weird US";
            private const string Description =  "In order to know is this extension can handle weird character ...from word !";

            public static string CompleteFeatureFile
            {
                get
                {
                    return "Feature: " + Title +
                           Environment.NewLine +
                           Description +
                           Environment.NewLine +
                           Environment.NewLine +
                           TestCaseResources.Word.CompleteFeatureTestCase +
                           Environment.NewLine +
                           Environment.NewLine +
                           TestCaseResources.Word.CompleteFeatureTestCase;
                }
            }


            private static TestCase CompleteTestCase
            {
                get
                {
                    return TestCase.Builder
                        .Name(TestCaseResources.Word.Name)
                        .Given(TestCaseResources.Word.Given.BaseStatement)
                        .Given(TestCaseResources.Word.GivenAnd.BaseStatement)
                        .When(TestCaseResources.Word.When.BaseStatement)
                        .Then(TestCaseResources.Word.Then.BaseStatement).Build();
                }
            }

            public static UserStory CompleteUserStory
            {
                get
                {
                    return UserStory.Builder
                        .Id(TestResource.IdUserStory)
                        .Title(Title)
                        .Description(Description)
                        .AddTestCase(CompleteTestCase)
                        .AddTestCase(CompleteTestCase)
                        .Build();
                }
            }
        }
    }

    public static class TestCaseResources
    {
        public static class Addition
        {
            public const string Name = "Addition calculation";

            public static readonly TestCaseTester Given = new TestCaseTester
                                                              {
                                                                  Type = StatementType.Given,
                                                                  BaseStatement = "Given the user \"Patrick\", type the number \"0123\"",
                                                                  BaseWihoutGherkin = "the user \"Patrick\", type the number \"0123\"",
                                                                  FinalMethodStatement = @"the user (.*), type the number (.*)",
                                                                  FinalStatement = "the user Patrick, type the number 0123",
                                                                  FeatureStatement = "Given the user Patrick, type the number 0123",
                                                                  Parameters = "string var1, int var2",
                                                                  MethodName = "TheUserTypeTheNumber",
                                                                  NumberOfParameters = 2,
                                                              };

            public static readonly TestCaseTester GivenAnd = new TestCaseTester
                                                                 {
                                                                     Type = StatementType.Given,
                                                                     BaseStatement = "And press the button \"+\"",
                                                                     BaseWihoutGherkin = "press the button \"+\"",
                                                                     FinalMethodStatement = @"press the button (.*)",
                                                                     FinalStatement = "press the button +",
                                                                     FeatureStatement = "And press the button +",
                                                                     Parameters = "string var1",
                                                                     MethodName = "PressTheButton",
                                                                     NumberOfParameters = 1,
                                                                 };

            public static readonly TestCaseTester GivenSecondAnd = new TestCaseTester
                                                                       {
                                                                           Type = StatementType.Given,
                                                                           BaseStatement = "And type the number \"456\"",
                                                                           BaseWihoutGherkin = "type the number \"456\"",
                                                                           FinalMethodStatement = @"type the number (.*)",
                                                                           FinalStatement = "type the number 456",
                                                                           FeatureStatement = "And type the number 456",
                                                                           Parameters = "int var1",
                                                                           MethodName = "TypeTheNumber",
                                                                           NumberOfParameters = 1,
                                                                       };

            public static readonly TestCaseTester When = new TestCaseTester
                                                             {
                                                                 Type = StatementType.When,
                                                                 BaseStatement = "When Patrick press the button Enter",
                                                                 BaseWihoutGherkin = "Patrick press the button Enter",
                                                                 FinalMethodStatement = "Patrick press the button Enter",
                                                                 FinalStatement = "Patrick press the button Enter",
                                                                 FeatureStatement = "When Patrick press the button Enter",
                                                                 Parameters = String.Empty,
                                                                 MethodName = "PatrickPressTheButtonEnter",
                                                                 NumberOfParameters = 0,
                                                             };

            public static readonly TestCaseTester WhenAnd = new TestCaseTester
                                                                {
                                                                    Type = StatementType.When,
                                                                    BaseStatement = "And whatch the screen result",
                                                                    BaseWihoutGherkin = "whatch the screen result",
                                                                    FinalMethodStatement = "whatch the screen result",
                                                                    FinalStatement = "whatch the screen result",
                                                                    FeatureStatement = "And whatch the screen result",
                                                                    Parameters = String.Empty,
                                                                    MethodName = "WhatchTheScreenResult",
                                                                    NumberOfParameters = 0,
                                                                };

            public static readonly TestCaseTester Then = new TestCaseTester
                                                             {
                                                                 Type = StatementType.Then,
                                                                 BaseStatement = "Then the result is displayed on the screen",
                                                                 BaseWihoutGherkin = "the result is displayed on the screen",
                                                                 FinalMethodStatement = "the result is displayed on the screen",
                                                                 FinalStatement = "the result is displayed on the screen",
                                                                 FeatureStatement = "Then the result is displayed on the screen",
                                                                 Parameters = String.Empty,
                                                                 MethodName = "TheResultIsDisplayedOnTheScreen",
                                                                 NumberOfParameters = 0,
                                                             };

            public static readonly TestCaseTester ThenAnd = new TestCaseTester
                                                                {
                                                                    Type = StatementType.Then,
                                                                    BaseStatement = "And the result is \"579\"",
                                                                    BaseWihoutGherkin = "the result is \"579\"",
                                                                    FinalMethodStatement = @"the result is (.*)",
                                                                    FinalStatement = "the result is 579",
                                                                    FeatureStatement = "And the result is 579",
                                                                    Parameters = "int var1",
                                                                    MethodName = "TheResultIs",
                                                                    NumberOfParameters = 1,
                                                                };

            public static TestCase CompleteTestCase
            {
                get
                {
                    return TestCase.Builder
                        .Name(Name)
                        .Given(Given.BaseStatement)
                        .Given(GivenAnd.BaseStatement)
                        .Given(GivenSecondAnd.BaseStatement)
                        .When(When.BaseStatement)
                        .When(WhenAnd.BaseStatement)
                        .Then(Then.BaseStatement)
                        .Then(ThenAnd.BaseStatement)
                        .Build();
                }
            }

            public static string CompleteFeatureTestCase
            {
                get
                {
                    return "Scenario: " + Name +
                           Environment.NewLine +
                           Given.FeatureStatement +
                           Environment.NewLine +
                           GivenAnd.FeatureStatement +
                           Environment.NewLine +
                           GivenSecondAnd.FeatureStatement +
                           Environment.NewLine +
                           When.FeatureStatement +
                           Environment.NewLine +
                           WhenAnd.FeatureStatement +
                           Environment.NewLine +
                           Then.FeatureStatement +
                           Environment.NewLine +
                           ThenAnd.FeatureStatement;
                }
            }
        }

        public static class GutterGame
        {
            public const string Name = "Gutter game";
            public const string Description = "In order to know my performance as a player I want the system calculate my total score";
            public const string Title = "Score calculation";

            public static readonly TestCaseTester Given = new TestCaseTester
                                                              {
                                                                  Type = StatementType.Given,
                                                                  BaseStatement = "Given a new bowling game",
                                                                  FinalMethodStatement = "a new bowling game",
                                                                  Parameters = String.Empty
                                                              };

            public static readonly TestCaseTester When = new TestCaseTester
                                                             {
                                                                 Type = StatementType.When,
                                                                 BaseStatement = "When all of my balls are landing in the gutter",
                                                                 FinalMethodStatement = "all of my balls are landing in the gutter",
                                                                 Parameters = String.Empty
                                                             };

            public static readonly TestCaseTester Then = new TestCaseTester
                                                             {
                                                                 Type = StatementType.Then,
                                                                 BaseStatement = "Then my total score should be 0",
                                                                 FinalMethodStatement = "my total score should be 0",
                                                                 Parameters = String.Empty
                                                             };

            public static readonly TestCaseTester And = new TestCaseTester
                                                            {
                                                                Type = StatementType.And,
                                                                BaseStatement = "And I'm very sad",
                                                                FinalMethodStatement = "I'm very sad",
                                                                Parameters = String.Empty
                                                            };

            public static string CompleteTestCase
            {
                get { return "Scenario: " + Name + Environment.NewLine + Given.BaseStatement + Environment.NewLine + When.BaseStatement + Environment.NewLine + Then.BaseStatement + Environment.NewLine + And.BaseStatement; }
            }

            public static string US_COMPLETE
            {
                get
                {
                    return "Feature: " + Title + Environment.NewLine + Description + Environment.NewLine +
                           Environment.NewLine + CompleteTestCase + Environment.NewLine +
                           Environment.NewLine + CompleteTestCase + Environment.NewLine +
                           Environment.NewLine + CompleteTestCase;
                }
            }
        }

        public static class Word
        {
            public const string Name = "Special US";


            public static readonly TestCaseTester Given = new TestCaseTester
            {
                Type = StatementType.Given,
                BaseStatement = " Given the user « Morgan », try to generate a specflow …",
                BaseWihoutGherkin = "the user « Morgan », try to generate a specflow …",
                FinalMethodStatement = @"the user (.*), try to generate a specflow ...",
                FinalStatement = "the user Morgan, try to generate a specflow ...",
                FeatureStatement = "Given the user Morgan, try to generate a specflow ...",
                Parameters = "string var1",
                MethodName = "TheUserTryToGenerateASpecflow",
                NumberOfParameters = 1,
            };

            public static readonly TestCaseTester GivenAnd = new TestCaseTester
            {
                Type = StatementType.Given,
                BaseStatement = "And the statement “I Try to detroy the world, isn’t it right?”",
                BaseWihoutGherkin = "the statement “I Try to detroy the world, isn’t it right?”",
                FinalMethodStatement = @"the statement (.*)",
                FinalStatement = "the statement I Try to detroy the world, isn't it right?",
                FeatureStatement = "And the statement I Try to detroy the world, isn't it right?",
                Parameters = "string var1",
                MethodName = "TheStatement",
                NumberOfParameters = 1,
            };

            public static readonly TestCaseTester When = new TestCaseTester
            {
                Type = StatementType.When,
                BaseStatement = "When he press the <button>",
                BaseWihoutGherkin = "he press the <button>",
                FinalMethodStatement = @"he press the <button>",
                FinalStatement = "he press the <button>",
                FeatureStatement = "When he press the <button>",
                Parameters = string.Empty,
                MethodName = "HePressTheButton",
                NumberOfParameters = 0,
            };
            
            public static readonly TestCaseTester Then = new TestCaseTester
            {
                Type = StatementType.Then,
                BaseStatement = "Then the statement is cleaned",
                BaseWihoutGherkin = "the statement is cleaned",
                FinalMethodStatement = @"the statement is cleaned",
                FinalStatement = "the statement is cleaned",
                FeatureStatement = "Then the statement is cleaned",
                Parameters = string.Empty,
                MethodName = "TheStatementIsCleaned",
                NumberOfParameters = 0,
            };

            public static string CompleteFeatureTestCase
            {
                get
                {
                    return "Scenario: " + Name +
                           Environment.NewLine +
                           Given.FeatureStatement +
                           Environment.NewLine +
                           GivenAnd.FeatureStatement +
                           Environment.NewLine +
                           When.FeatureStatement +
                           Environment.NewLine +
                           Then.FeatureStatement;
                }
            }
        }
    }

}
